import 'package:flutter/material.dart';
import './movie/list.dart';
import './movie/Detail.dart';
import './Login/login.dart';
import './search/search.dart';
import './Routes.dart';
import './keshihua.dart';
import './n.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  var routes = {
    '/': (context) => MyHomePage(),
    '/detail': (context, {arguments}) => Detail(arguments: arguments),
    '/login':(context) => Login(),
    '/search':(context) => Search(),
    '/sc':(context)=> Namesc(),
    '/keshihua': (context)=>MyApps(),
    '/video':(context,{arguments}) => Video(arguments: arguments),
  };
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        initialRoute: '/login',
        onGenerateRoute: (RouteSettings settings) {
          final String name = settings.name;
          final Function pageContentBuilder = routes[name];
          if (pageContentBuilder != null) {
            if (settings.arguments != null) {
              final Route route = MaterialPageRoute(
                  builder: (context) => pageContentBuilder(context,
                      arguments: settings.arguments));
              return route;
            } else {
              final Route route = MaterialPageRoute(
                  builder: (context) => pageContentBuilder(context));
              return route;
            }
          }
        });
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
            appBar: AppBar(
              title: Text('电影列表'),
              
              centerTitle: true,
              backgroundColor: Colors.red,
              elevation: 0,
              actions: <Widget>[
                new PopupMenuButton(
            onSelected: (String value){
               Navigator.pushNamed(context, value);
            },
              itemBuilder: (BuildContext context) =><PopupMenuItem<String>>[
                new PopupMenuItem(
                    value:"/search",
                    child: Text('搜索电影'),
                    
                    
                ),
                new PopupMenuItem(
                  value: "/sc",
                    child: new Text("北美票房")
                )
              ]
          )

              ],
              
            ),
            drawer: Drawer(
              child: ListView(
                padding: EdgeInsets.all(0),
                children: <Widget>[
                  UserAccountsDrawerHeader(
                    
                    accountName: Text('标题一'),
                    accountEmail: Text('npm.com'),
                    currentAccountPicture: CircleAvatar(
                      backgroundImage: NetworkImage(
                          "https://i0.hdslb.com/bfs/sycp/creative_img/202004/9f55edc76980f69d179d9bc533922512.jpg"),
                    ),
                    decoration: BoxDecoration(
                        // 设置背景图片
                        image: DecorationImage(
                            // 背景图片的属性
                            fit: BoxFit.cover,
                            // 背景图片
                            image: NetworkImage(
                                'https://www.itying.com/images/flutter/3.png'))),
                  ),
                  ListTile(title: Text('用户反馈'), trailing: Icon(Icons.feedback),onTap: (){
                    Navigator.pushNamed(context, '/keshihua');
                    print('sds');
                  },),
                  Divider(),
                  ListTile(title: Text('系统设置'), trailing: Icon(Icons.settings),onTap: (){
                    showDialog(context: context,child: AlertDialog(content: Text("holle word", style: TextStyle())));
                  },),
                  Divider(),
                  ListTile(title: Text('我要发布'), trailing: Icon(Icons.send)),
                  Divider(),
                  ListTile(
                      title: Text('反馈'), trailing: Icon(Icons.exit_to_app)),
                ],
              ),
            ),
            bottomNavigationBar: Container(
                decoration: BoxDecoration(color: Colors.black),
                height: 50,
                child: TabBar(
                    labelStyle: TextStyle(height: 0, fontSize: 10),
                    tabs: <Widget>[
                      Tab(icon: Icon(Icons.movie_filter), text: '正在热映'),
                      Tab(icon: Icon(Icons.movie_creation), text: '即将上映'),
                      Tab(icon: Icon(Icons.local_movies), text: 'top250')
                    ])),
            body: TabBarView(children: <Widget>[
              List(mt: 'in_theaters'),
              List(mt: 'coming_soon'),
              List(mt: 'top250'),
            ])));
  }
}
